package com.learn.factory.method;

import com.learn.factory.method.factory.BeijingFactory;
import com.learn.factory.method.factory.WuhanFactory;

/**
 * <p>项目名称: design-pattern </p>
 *
 * <p>文件名称: App </p>
 *
 * The Factory Method is a creational design pattern which uses factory methods to deal with the
 * problem of creating objects without specifying the exact class of object that will be created.
 * This is done by creating objects via calling a factory method either specified in an interface
 * and implemented by child classes, or implemented in a base class and optionally overridden by
 * derived classes—rather than by calling a constructor.
 * <p>
 * In this Factory Method example we have an interface ({@link Factory}) with a method for
 * creating objects ({@link Factory #makeWeapon}).
 * The concrete subclasses ({@link BeijingFactory}, {@link WuhanFactory})
 * then override the method to produce objects of their liking.
 */
public class App {

    public static void main(String[] args) {
        BeijingFactory beijingFactory = new BeijingFactory();
        beijingFactory.makeWeapon(WeaponType.SHORT_SWORD);
        beijingFactory.makeWeapon(WeaponType.SPEAR);

        WuhanFactory wuhanFactory = new WuhanFactory();
        wuhanFactory.makeWeapon(WeaponType.SHORT_SWORD);
        wuhanFactory.makeWeapon(WeaponType.SPEAR);
    }
}
